#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int hour, min;
    if (d - b < 0)
    {
        min = 60 + d - b;
        hour = c - a - 1;
    }
    else
    {
        min = b - d;
        hour = c - a;
    }

    cout << hour << " " <<min<< endl;
    return 0;
}